Skip to content

Source generator tweaks #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 7, 2022
Merged

Source generator tweaks #1178

merged 2 commits into from
Sep 7, 2022

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Aug 9, 2022

This PR adds the following header comment to auto-generated controller classes:

// <auto-generated />

The comment instructs other analyzers, such as StyleCop, to skip analyzing such files, so you won't get suggestions or warnings in them.

I've also updated the project to C# 10, so we can use static lambdas to avoid accidental closure allocations.

On my 6-year-old home computer, building the integration tests project takes ~40 seconds. I suspect this is caused by our controller source generator (the project contains a large number of resources). So I explored switching to incremental source generators, until I realized they can only potentially improve IDE IntelliSense performance and don't improve the speed of command-line builds. Furthermore, there are lots of open bugs and some users report a massive increase in memory usage. Therefore I aborted this effort.

I also tried to reduce the number of Compilation lookups, replacing them with hardcoded qualified type names. But this did not result in measurable performance improvements. These lookups are probably cached inside roslyn.

QUALITY CHECKLIST

  • Changes implemented in code
  • Complies with our contributing guidelines
  • N/A: Adapted tests
  • N/A: Documentation updated

… captured variables, potentially resulting in unintended allocations
@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #1178 (549586b) into master (0185311) will increase coverage by 0.00%.
The diff coverage is 97.86%.

@@           Coverage Diff           @@
##           master    #1178   +/-   ##
=======================================
  Coverage   92.58%   92.58%           
=======================================
  Files         241      241           
  Lines        7700     7703    +3     
=======================================
+ Hits         7129     7132    +3     
  Misses        571      571           
Impacted Files Coverage Δ
...ApiDotNetCore.SourceGenerators/SourceCodeWriter.cs 97.56% <97.50%> (+0.08%) ⬆️
...Core.SourceGenerators/ControllerSourceGenerator.cs 98.43% <98.43%> (-0.03%) ⬇️
...ourceGenerators/TypeWithAttributeSyntaxReceiver.cs 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.

@bkoelman bkoelman requested a review from maurei August 10, 2022 01:13
@maurei maurei merged commit ca14796 into master Sep 7, 2022
@maurei maurei deleted the source-generator-tweaks branch September 7, 2022 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants